﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using BL;

namespace WindowsFormsApplication1
{
    public partial class frmTheoDoiCongNhan : Form
    {
        TheoDoiCongNhanBL theoDoiCongNhanBL;
        DataTable dttheoDoiCongNhanTheoThang = null;
        DataSet dstheoDoiCongNhanTheoThang;

        DataTable dttheoDoiCongNhanTheoMaDonHang = null;
        DataSet dstheoDoiCongNhanTheoMaDonHang;

        public frmTheoDoiCongNhan()
        {
            InitializeComponent();
            theoDoiCongNhanBL = new TheoDoiCongNhanBL();
        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

        }

        private void tabPage4_Click(object sender, EventArgs e)
        {

        }

        private void chart1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void btnXemCN_Click(object sender, EventArgs e)
        {
            try
            {
                dgvLoiCNTheoThang.AutoGenerateColumns = false;
                string thang = dtpLoiCongNhanTheoThang.Value.Month.ToString();
                string nam = dtpLoiCongNhanTheoThang.Value.Year.ToString(); 

                //string thangNam = dtpLoiCongNhanTheoThang.Value.ToString("MM");
                dstheoDoiCongNhanTheoThang = theoDoiCongNhanBL.loiCongNhanTheoThang(thang, nam);
                dgvLoiCNTheoThang.DataSource = dstheoDoiCongNhanTheoThang.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            try
            {
                dgvLoiCongNhanTheoDonHang.AutoGenerateColumns = false;
                dstheoDoiCongNhanTheoMaDonHang = theoDoiCongNhanBL.loiCongNhanTheoDonHang(txtMaDonHang.Text);
                dgvLoiCongNhanTheoDonHang.DataSource = dstheoDoiCongNhanTheoMaDonHang.Tables[0];
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            //    dgvcongnhan1.AutoGenerateColumns = false;
            //    dsCongNhan = congNhanBL.layDanhSachCongNhan();
            //    //dgvcongnhan1.DataSource = ketnoi.ex("select * from CongNhan");
            //    bs.DataSource = dsCongNhan.Tables[0];
            //    dgvcongnhan1.DataSource = bs;            
        }
    }
}
